/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package interfaces;

import datos.Administrador;
import datos.Coordinador;
import negocios.GestorUsuarios;
import datos.Operador;
import datos.ResponsableEntidad;
import datos.Usuario;
import exceptions.*;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;

/**
 *
 * @author miguesaca
 */
public class Panel_CallCenter extends Panel_T {

    private String nombreUsuario, contrasena, cedula, nombre, apellido, telefono, direccion,cedulaBusqueda,opcion;
    private boolean buscar;
    private Operador operador;
    private Coordinador coordinador;
    private Administrador administrador;
    private ResponsableEntidad responsableEntidad;
    private Ventana ventana;
    
    public Panel_CallCenter(Ventana ventana) {
        this.ventana = ventana;
        this.buscar = false;
        this.opcion = "----";
        initComponents();

    }

    public void getTabla_Listado(javax.swing.table.DefaultTableModel tablaModelo) {
        Tabla_Listado.setModel(tablaModelo);
        // Instanciamos el TableRowSorter y lo añadimos al JTable Para ordenarlo
        TableRowSorter<TableModel> elQueOrdena = new TableRowSorter<TableModel>(tablaModelo);
        Tabla_Listado.setRowSorter(elQueOrdena);
        getTabla_ListaResuminda(tablaModelo);
    }
    private void getTabla_ListaResuminda(javax.swing.table.DefaultTableModel tablaModelo) {
        Tabla_ListaResumida.setModel(tablaModelo);
        //para suprimir algunas columnas
        TableColumnModel tcm = Tabla_ListaResumida.getColumnModel();
        // Se pide la columna por su número, empezando en cero.
        TableColumn columnaABorrar1 = tcm.getColumn(2); 
        TableColumn columnaABorrar2 = tcm.getColumn(3); 
        TableColumn columnaABorrar3 = tcm.getColumn(5); 
        Tabla_ListaResumida.removeColumn (columnaABorrar1);
        Tabla_ListaResumida.removeColumn (columnaABorrar2);
        Tabla_ListaResumida.removeColumn (columnaABorrar3);
        // Instanciamos el TableRowSorter y lo añadimos al JTable Para ordenarlo
        TableRowSorter<TableModel> elQueOrdena = new TableRowSorter<TableModel>(tablaModelo);
        Tabla_ListaResumida.setRowSorter(elQueOrdena);
    }
   private void guardar(){
    try {
           
          
            contrasena = text_Password.getText();
            text_Password.setText("");
            cedula = text_Cedula.getText();
            text_Cedula.setText("");
            nombre = text_Nombre.getText();
            text_Nombre.setText("");
            apellido = text_Apellido.getText();
            text_Apellido.setText("");
            telefono = text_Telefono.getText();
            text_Telefono.setText("");
            direccion = text_Direccion.getText();
            text_Direccion.setText("");
            if(opcion.equalsIgnoreCase("Operador")){
                operador = new Operador(nombreUsuario, contrasena, cedula, nombre, apellido, telefono, direccion);
                
                ventana.getGestorOperadoras().insertar(operador);
            }else if(opcion.equalsIgnoreCase("Coordinador")){
                coordinador = new Coordinador(nombreUsuario, contrasena, cedula, nombre, apellido, telefono, direccion);
                ventana.getGestorCoordinadores().insertar(coordinador);
            }else if(opcion.equalsIgnoreCase("Administrador")){
                administrador = new Administrador(nombreUsuario, contrasena, cedula, nombre, apellido, telefono, direccion);
                ventana.getGestorAdministradores().insertar(administrador);
            }else if(opcion.equalsIgnoreCase("ResponsableEntidad")){
                responsableEntidad = new ResponsableEntidad(nombreUsuario, contrasena, cedula, nombre, apellido, telefono, direccion);
                ventana.getGestorResponsableEntidad().insertar(responsableEntidad);
            }else if(opcion.equalsIgnoreCase("----")){
                 JOptionPane.showMessageDialog(null, "Seleccione por favor");
             } 
                
            
        }  catch (UsuarioException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        }  catch (AlfanumericoException ex) {
            JOptionPane.showMessageDialog(null,ex.getMessage());} catch (SQLException ex) {
            Logger.getLogger(Panel_CallCenter.class.getName()).log(Level.SEVERE, null, ex);
        }
        ventana.actualizar(opcion);
   }
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tabbedPanel_CallCenter = new javax.swing.JTabbedPane();
        panel_Edicion = new Panel_T();
        jPanel1 = new Panel_T();
        boton_Busqueda = new javax.swing.JButton();
        label_Modificar = new javax.swing.JLabel();
        label_CedulaBusqueda = new javax.swing.JLabel();
        text_CedulaBusqueda = new javax.swing.JTextField();
        jPanel2 = new Panel_T();
        jLabel2 = new javax.swing.JLabel();
        text_Cedula = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        text_Nombre = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        text_Apellido = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        text_Telefono = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        boton_Actualizar = new javax.swing.JButton();
        boton_Guardar = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        text_Direccion = new javax.swing.JTextField();
        text_Password = new javax.swing.JTextField();
        jPanel4 = new Panel_T();
        jScrollPane2 = new javax.swing.JScrollPane();
        Tabla_ListaResumida = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        tipo_Emergencia = new javax.swing.JComboBox();
        jLabel10 = new javax.swing.JLabel();
        Panel_Listado = new Panel_T();
        jScrollPane1 = new javax.swing.JScrollPane();
        Tabla_Listado = new javax.swing.JTable();

        setBackground(new java.awt.Color(38, 99, 160));

        jPanel1.setBackground(new java.awt.Color(102, 102, 102));

        boton_Busqueda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icon_buscar1.png"))); // NOI18N
        boton_Busqueda.setBorderPainted(false);
        boton_Busqueda.setContentAreaFilled(false);
        boton_Busqueda.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        boton_Busqueda.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        boton_Busqueda.setIconTextGap(-3);
        boton_Busqueda.setPreferredSize(new java.awt.Dimension(50, 50));
        boton_Busqueda.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icon_buscar2.png"))); // NOI18N
        boton_Busqueda.setRolloverEnabled(true);
        boton_Busqueda.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icon_buscar0.png"))); // NOI18N
        boton_Busqueda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boton_BusquedaActionPerformed(evt);
            }
        });

        label_Modificar.setText("M O D I F I C A R");

        label_CedulaBusqueda.setText("Cedula:");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(66, 66, 66)
                .addComponent(label_CedulaBusqueda)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(text_CedulaBusqueda, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(boton_Busqueda, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(label_Modificar))
                .addContainerGap(21, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(7, 7, 7)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(boton_Busqueda, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(label_Modificar)
                        .addGap(52, 52, 52)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(text_CedulaBusqueda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(label_CedulaBusqueda))))
                .addContainerGap(112, Short.MAX_VALUE))
        );

        jPanel2.setBackground(new java.awt.Color(102, 102, 102));

        jLabel2.setText("I N S E R T A R");

        jLabel3.setText("Cedula:");

        jLabel4.setText("Nombre:");

        jLabel5.setText("Telefono:");

        jLabel6.setText("Apellido:");

        boton_Actualizar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icon_modificar1.png"))); // NOI18N
        boton_Actualizar.setBorderPainted(false);
        boton_Actualizar.setContentAreaFilled(false);
        boton_Actualizar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        boton_Actualizar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        boton_Actualizar.setIconTextGap(-3);
        boton_Actualizar.setPreferredSize(new java.awt.Dimension(50, 50));
        boton_Actualizar.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icon_modificar2.png"))); // NOI18N
        boton_Actualizar.setRolloverEnabled(true);
        boton_Actualizar.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icon_modificar0.png"))); // NOI18N
        boton_Actualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boton_ActualizarActionPerformed(evt);
            }
        });

        boton_Guardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icon_guardar1.png"))); // NOI18N
        boton_Guardar.setBorderPainted(false);
        boton_Guardar.setContentAreaFilled(false);
        boton_Guardar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        boton_Guardar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        boton_Guardar.setIconTextGap(-3);
        boton_Guardar.setPreferredSize(new java.awt.Dimension(50, 50));
        boton_Guardar.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icon_gestion2.png"))); // NOI18N
        boton_Guardar.setRolloverEnabled(true);
        boton_Guardar.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icon_guardar0.png"))); // NOI18N
        boton_Guardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boton_GuardarActionPerformed(evt);
            }
        });

        jLabel7.setText("Direccion:");

        jLabel9.setText("Password:");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(203, Short.MAX_VALUE)
                .addComponent(jLabel2)
                .addGap(133, 133, 133))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4))
                        .addGap(11, 11, 11)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(text_Cedula, javax.swing.GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE)
                            .addComponent(text_Nombre))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(text_Apellido)
                            .addComponent(text_Telefono)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(text_Direccion))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addGap(20, 20, 20)
                        .addComponent(text_Password, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(boton_Guardar, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(boton_Actualizar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(text_Cedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3)
                    .addComponent(jLabel5)
                    .addComponent(text_Telefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(text_Nombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(jLabel6)
                    .addComponent(text_Apellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(text_Direccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(28, 28, 28)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(text_Password, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel9))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(boton_Guardar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(boton_Actualizar, javax.swing.GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE))
                        .addContainerGap())))
        );

        jPanel4.setBackground(new java.awt.Color(102, 102, 102));

        Tabla_ListaResumida.setBackground(new java.awt.Color(204, 204, 204));
        Tabla_ListaResumida.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Cedula", "LoginNombre", "Telefono"
            }
        ));
        Tabla_ListaResumida.setColumnSelectionAllowed(true);
        Tabla_ListaResumida.setOpaque(false);
        jScrollPane2.setViewportView(Tabla_ListaResumida);
        Tabla_ListaResumida.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);

        jLabel1.setText("L I S T A   D E   O P E R A D O R A S");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 543, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(159, 159, 159)
                        .addComponent(jLabel1)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE)
                .addContainerGap())
        );

        tipo_Emergencia.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "----", "Operador", "Administrador", "Coordinador", "ResponsableEntidad" }));
        tipo_Emergencia.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                tipo_EmergenciaItemStateChanged(evt);
            }
        });

        jLabel10.setText("Tipos de Usuario");

        javax.swing.GroupLayout panel_EdicionLayout = new javax.swing.GroupLayout(panel_Edicion);
        panel_Edicion.setLayout(panel_EdicionLayout);
        panel_EdicionLayout.setHorizontalGroup(
            panel_EdicionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_EdicionLayout.createSequentialGroup()
                .addGroup(panel_EdicionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panel_EdicionLayout.createSequentialGroup()
                        .addGroup(panel_EdicionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(panel_EdicionLayout.createSequentialGroup()
                                .addGap(37, 37, 37)
                                .addComponent(tipo_Emergencia, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(panel_EdicionLayout.createSequentialGroup()
                                .addGap(53, 53, 53)
                                .addComponent(jLabel10)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panel_EdicionLayout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(38, Short.MAX_VALUE))
        );
        panel_EdicionLayout.setVerticalGroup(
            panel_EdicionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panel_EdicionLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panel_EdicionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGroup(panel_EdicionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panel_EdicionLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(panel_EdicionLayout.createSequentialGroup()
                        .addGap(62, 62, 62)
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tipo_Emergencia, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        tabbedPanel_CallCenter.addTab("Operadora", panel_Edicion);

        Tabla_Listado.setBackground(new java.awt.Color(204, 204, 204));
        Tabla_Listado.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Cedula", "Nombre", "Telefono", "Edad"
            }
        ));
        Tabla_Listado.setColumnSelectionAllowed(true);
        Tabla_Listado.setOpaque(false);
        jScrollPane1.setViewportView(Tabla_Listado);
        Tabla_Listado.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);

        javax.swing.GroupLayout Panel_ListadoLayout = new javax.swing.GroupLayout(Panel_Listado);
        Panel_Listado.setLayout(Panel_ListadoLayout);
        Panel_ListadoLayout.setHorizontalGroup(
            Panel_ListadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Panel_ListadoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 790, Short.MAX_VALUE)
                .addContainerGap())
        );
        Panel_ListadoLayout.setVerticalGroup(
            Panel_ListadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Panel_ListadoLayout.createSequentialGroup()
                .addGap(101, 101, 101)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(167, Short.MAX_VALUE))
        );

        tabbedPanel_CallCenter.addTab("Listado", Panel_Listado);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(tabbedPanel_CallCenter, javax.swing.GroupLayout.PREFERRED_SIZE, 815, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tabbedPanel_CallCenter)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void tipo_EmergenciaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_tipo_EmergenciaItemStateChanged
        // TODO add your handling code here:
        if (evt.getStateChange() == 1) {
            opcion = (String)evt.getItem();
            ventana.actualizar(opcion);
        }
    }//GEN-LAST:event_tipo_EmergenciaItemStateChanged

    private void boton_GuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_GuardarActionPerformed
        // TODO add your handling code here:
        guardar();
    }//GEN-LAST:event_boton_GuardarActionPerformed

    private void boton_ActualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_ActualizarActionPerformed
        // TODO add your handling code here:
        if(buscar)
        guardar();
        buscar = false;
    }//GEN-LAST:event_boton_ActualizarActionPerformed

    private void boton_BusquedaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boton_BusquedaActionPerformed
        Usuario usuario = new Usuario();
        try {
            // TODO add your handling code here:
            cedulaBusqueda = text_CedulaBusqueda.getText(); text_CedulaBusqueda.setText("");
            
            if(opcion.equalsIgnoreCase("Operador")){
                operador =ventana.getGestorOperadoras().buscar(cedulaBusqueda);
                usuario = operador;
                //ventana.getGestorOperadoras().eliminar(cedulaBusqueda);
            }else if(opcion.equalsIgnoreCase("Coordinador")){
                coordinador =ventana.getGestorCoordinadores().buscar(cedulaBusqueda);
                usuario = coordinador;
                //ventana.getGestorCoordinadores().eliminar(cedulaBusqueda);
            }else if(opcion.equalsIgnoreCase("Administrador")){
                administrador =ventana.getGestorAdministradores().buscar(cedulaBusqueda);
                usuario = administrador;
                //ventana.getGestorAdministradores().eliminar(cedulaBusqueda);
            }else if(opcion.equalsIgnoreCase("ResponsableEntidad")){
                responsableEntidad =ventana.getGestorResponsableEntidad().buscar(cedulaBusqueda);
                usuario = responsableEntidad;
                //ventana.getGestorAdministradores().eliminar(cedulaBusqueda);
            }else if(opcion.equalsIgnoreCase("----")){
                JOptionPane.showMessageDialog(null, "Seleccione por favor");
            }
        } catch (UsuarioException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        }
        if(usuario != null){
        
           
            contrasena = usuario.getContrasena();
            text_Password.setText(contrasena);
            cedula = usuario.getCedula();
            text_Cedula.setText(cedula);
            nombre = usuario.getNombre();
            text_Nombre.setText(nombre);
            apellido = usuario.getApellido();
            text_Apellido.setText(apellido);
            telefono = usuario.getTelefono();
            text_Telefono.setText(telefono);
            direccion = usuario.getDireccion();
            text_Direccion.setText(direccion);
            buscar = true;
        }else{
            JOptionPane.showMessageDialog(null, "No se encuentra registrado");
        }
        
    }//GEN-LAST:event_boton_BusquedaActionPerformed

    public String getOpcion() {
        return opcion;
    }

    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel Panel_Listado;
    private javax.swing.JTable Tabla_ListaResumida;
    private javax.swing.JTable Tabla_Listado;
    private javax.swing.JButton boton_Actualizar;
    private javax.swing.JButton boton_Busqueda;
    private javax.swing.JButton boton_Guardar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel label_CedulaBusqueda;
    private javax.swing.JLabel label_Modificar;
    private javax.swing.JPanel panel_Edicion;
    private javax.swing.JTabbedPane tabbedPanel_CallCenter;
    private javax.swing.JTextField text_Apellido;
    private javax.swing.JTextField text_Cedula;
    private javax.swing.JTextField text_CedulaBusqueda;
    private javax.swing.JTextField text_Direccion;
    private javax.swing.JTextField text_Nombre;
    private javax.swing.JTextField text_Password;
    private javax.swing.JTextField text_Telefono;
    private javax.swing.JComboBox tipo_Emergencia;
    // End of variables declaration//GEN-END:variables
}
